#!/bin/sh
# - runtime
# - rw
# - bs
# - ioengine
# - fallocate
# - sub_group_number
# - group_file_number

## fio  is  a  tool that will spawn a number of threads or processes
## doing a particular type of I/O action as specified by the user.
## The typical use of fio is to write a job file matching
## the I/O load one wants to simulate.

echo runtime=$runtime
echo rw=$rw
echo bs=$bs
echo ioengine=$ioengine
echo fallocate=$fallocate
echo size=$size

: ${bs:=4k}
: ${size:=10G}
: ${fallocate:=posix}

export blocksize=$bs

if [ -z "$jobfile" ]; then
	. $(dirname $0)/$testcase
fi

copy-results $jobfile

# Clean memory cached
sync && echo 3 > /proc/sys/vm/drop_caches
command="fio $RESULT_ROOT/results/$jobfile --output-format=json"
date=$(date +'%F %T')
echo "$date $command" | tee -a $RESULT_ROOT/reproduce.sh
exec $command > $RESULT_ROOT/fio_output.json
